From 4500e4f9fa9030bebe1a0a65e2b3634b1122772b Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C3=98yvind=20Kol=C3=A5s?= Date: Tue, 31 Oct 2017 20:48:23 +0100 Subject: [PATCH] babl: add babl_format_exists A function to check if a specific format - by name - is already known by babl. Should be used in conjunction with babl_format() for user supplied format strings. --- babl/babl-format.c | 9 +++++++++ babl/babl.h | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/babl/babl-format.c b/babl/babl-format.c index 079272c..45c62b2 100644 --- a/babl/babl-format.c +++ b/babl/babl-format.c @@ -748,4 +748,13 @@ babl_format_with_space (const char *name, const Babl *space) return ret; } +int +babl_format_exists (const char *name) +{ + if (babl_db_exist_by_name (db, name)) + return 1; + return 0; +} + + diff --git a/babl/babl.h b/babl/babl.h index 5e299a7..a45de42 100644 --- a/babl/babl.h +++ b/babl/babl.h @@ -156,6 +156,15 @@ char *babl_icc_get_key (const char *icc_data, */ const Babl * babl_format (const char *name); +/** + * babl_format_exists: + * + * Returns 1 if the provided format name is known by babl or 0 if it is + * not. Can also be used to verify that specific extension formats are + * available (though this can also be inferred from the version of babl). + */ +int babl_format_exists (const char *name); + /** * babl_format_with_space: * -- 2.30.2